package com.ly.heart.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.ly.common.core.domain.AjaxResult;
import com.ly.common.utils.DateUtils;
import com.ly.common.utils.SecurityUtils;
import com.ly.common.utils.erp.SnowflakeIdWorker;
import com.ly.heart.mapper.WarehouseMaxMinInventoryMapper;
import com.ly.heart.service.IWarehouseMaxMinInventoryService;
import org.springframework.stereotype.Service;
import com.ly.heart.domain.WarehouseMaxMinInventoryEntity;

import javax.annotation.Resource;


/**
 * 仓库最大最小安全库存Service业务层处理
 * @author cxl
 * @date 2024-07-26
 */
@Service
public class WarehouseMaxMinInventoryServiceImpl extends ServiceImpl<WarehouseMaxMinInventoryMapper, WarehouseMaxMinInventoryEntity> implements IWarehouseMaxMinInventoryService {

    @Resource
    private WarehouseMaxMinInventoryMapper warehouseMaxMinInventoryMapper;

    /**
     * 查询仓库最大最小安全库存
     * @param id 仓库最大最小安全库存ID
     * @return 仓库最大最小安全库存
     */
    @Override
    public WarehouseMaxMinInventoryEntity selectWarehouseMaxMinInventoryEntityById (String id) {
        return warehouseMaxMinInventoryMapper.selectWarehouseMaxMinInventoryEntityById ( id );
    }

    /**
     * 查询仓库最大最小安全库存列表
     * @param warehouseMaxMinInventoryEntity 仓库最大最小安全库存
     * @return 仓库最大最小安全库存
     */
    @Override
    public AjaxResult selectWarehouseMaxMinInventoryEntityList (WarehouseMaxMinInventoryEntity warehouseMaxMinInventoryEntity) {
        Page<WarehouseMaxMinInventoryEntity> page = this.page ( new Page<WarehouseMaxMinInventoryEntity> ( warehouseMaxMinInventoryEntity.getPage (), warehouseMaxMinInventoryEntity.getLimit () ) );
        return AjaxResult.success (page);
        //return warehouseMaxMinInventoryMapper.selectWarehouseMaxMinInventoryEntityList ( warehouseMaxMinInventoryEntity );
    }

    /**
     * 新增仓库最大最小安全库存
     * @param warehouseMaxMinInventoryEntity 仓库最大最小安全库存
     * @return 结果
     */
    @Override
    public int insertWarehouseMaxMinInventoryEntity (WarehouseMaxMinInventoryEntity warehouseMaxMinInventoryEntity) {
        warehouseMaxMinInventoryEntity.setId ( SnowflakeIdWorker.getInstance ().nextStringId () );
        warehouseMaxMinInventoryEntity.setCreateBy ( SecurityUtils.getLoginUser ().getUser ().getUserId () );
        warehouseMaxMinInventoryEntity.setCreateTime ( DateUtils.getNowDate () );
        return warehouseMaxMinInventoryMapper.insertWarehouseMaxMinInventoryEntity ( warehouseMaxMinInventoryEntity );
    }

    /**
     * 修改仓库最大最小安全库存
     * @param warehouseMaxMinInventoryEntity 仓库最大最小安全库存
     * @return 结果
     */
    @Override
    public int updateWarehouseMaxMinInventoryEntity (WarehouseMaxMinInventoryEntity warehouseMaxMinInventoryEntity) {
        warehouseMaxMinInventoryEntity.setUpdateBy ( SecurityUtils.getLoginUser ().getUser ().getUserId () );
        warehouseMaxMinInventoryEntity.setUpdateTime ( DateUtils.getNowDate () );
        return warehouseMaxMinInventoryMapper.updateWarehouseMaxMinInventoryEntity ( warehouseMaxMinInventoryEntity );
    }

    /**
     * 批量删除仓库最大最小安全库存
     * @param ids 需要删除的仓库最大最小安全库存ID
     * @return 结果
     */
    @Override
    public int deleteWarehouseMaxMinInventoryEntityByIds (String[] ids) {
        return warehouseMaxMinInventoryMapper.deleteWarehouseMaxMinInventoryEntityByIds ( ids );
    }

    /**
     * 删除仓库最大最小安全库存信息
     * @param id 仓库最大最小安全库存ID
     * @return 结果
     */
    @Override
    public int deleteWarehouseMaxMinInventoryEntityById (String id) {
        return warehouseMaxMinInventoryMapper.deleteWarehouseMaxMinInventoryEntityById ( id );
    }
}
